<template>
    <div class="newInfo-container">
        <h3 class="title">{{ newsInfo.title }}</h3>
        <p class="subtitle">
            <span>发表时间：{{ newsInfo.add_time | dateFormat }}</span>
            <span>点击{{ newsInfo.click }}次</span>
        </p>
        <hr>
        <div class="content" v-html="newsInfo.content"></div>
        <comment-box :id="this.id"> </comment-box>
    </div>
</template>
<script>
import { Toast } from 'mint-ui'
import comment from '../subcomponents/comment.vue'

export default {
    data(){
        return {
            id: this.$route.params.id,
            newsInfo:{}
        }
    },
    components:{
        'comment-box':comment
    },
    created() {
        this.getNewsInfo()
    },
    methods:{
        getNewsInfo(){
            this.$http.get('api/getnew/'+this.id).then(result => {
                if(result.body.status === 0){
                    // console.log(result.body)
                    this.newsInfo = result.body.message[0] 
                }else{
                    Toast('获取新闻详情失败')
                }
            }

            )

        }
    }
}
</script>
<style lang="scss">
.newInfo-container{
    .title{
        text-align: center;
        margin: 10px 0;

    }
    .subtitle{
                font-size: 12px;
                display: flex;
                justify-content: space-between;
                
    }
    .content{
        margin: 0;
        img{
            width: 100%;
        }
    }
}
</style>